import React, { useEffect } from 'react'
import {Button} from 'antd-mobile'
import NavBarBox from '../../components/NavBar'
import { useNavigate } from 'react-router-dom'
const My = () => {
  const userInfo=JSON.parse(localStorage.getItem('userInfo'))||{}
  const navigate=useNavigate()
  const handleToken=()=>{
    const token=localStorage.getItem('token');
    if(!token){
        navigate('/denglu')
    }
  }
  useEffect(()=>{
    handleToken()
  })
  return (
    <div>
      <NavBarBox title="我的" />
      {/* 进入我的页面后，找一张图片作为用户头像，给用户设置一个任意名称的昵称 */}
      <img src={userInfo.avatar} alt="" />
      <h1>{userInfo.nickname}</h1>
      <div style={{
        display: 'flex',
        justifyContent: 'space-around',
      }}>
        {/* 1.我的页面点击收藏按钮，跳转到收藏页面，将收藏过的演出展示在页面中 */}
      <Button onClick={()=>navigate('/collection')} color='primary'>我的收藏</Button>
      <Button onClick={()=>navigate('/server')} color='danger'>在线咨询</Button>
      </div>
    </div>
  )
}

export default My
